new Vue({
  el: '#app',
  data() {
    return {
      form: {
        Data: 'function_type',//状态
        Primary_Key:'',
        Primary_Key_Name:'Function_Type_Name',
        isVague:true,
        page: 1,			//页数
        limit: 10			//每页数据条数
      },
      tableData: [],		//表格数据
      total: 1,
    }
  },
  mounted() {
    this.getList(this.form)
  },
  methods: {
    onSerach() {				//查询方法  
      this.form.page = 1
      this.getList(this.form)
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    getList(data) {     //换页方法
      let _this = this
      $.ajax({
        type: 'POST',
        url: DomainName + "/getTableInquiryAction?token=" + $.cookie('token'),
        data,
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = absolutepath()  + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result.tableData      //将获取的数据存到表格数据中
          _this.total = Number(Result.limit)
        },
        dataType: "json"
      });
    },
    Add() {
      window.location.href = './Add.html'
    },
    Edit(Function_Type_SerialNumber) {
      sessionStorage.setItem("Function_Type_SerialNumber", Function_Type_SerialNumber)
      window.location.href = './Edit.html?Function_Type_SerialNumber=' + Function_Type_SerialNumber
    },
    Delete(Function_Type_SerialNumber) {
      const _this = this
      this.$confirm('此操作将删除该模板类型, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        $.ajax({
          url: DomainName + '/DeleteAction?token=' +$.cookie('token'),
          type: 'POST',
          data:{
            TableName:'approval_type',
            Primary_Key:Function_Type_SerialNumber,
            Primary_Key_Name:'Function_Type_SerialNumber',
            Operation_Name:'删除审批模板类型'
          },
          success: function (res) {
            if (res.Status == 'success') {
              _this.getList(_this.form);
              _this.$message({
                type: 'success',
                message:'删除成功!'
              });
            }
          },
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          }
        })
      }).catch(() => {
        this.$message({
          type: 'warning',
          message: '已取消操作'
        });
      });
    },
  },
})